<!DOCTYPE html>



  


<html class="theme-next pisces use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="theme-color" content="#222">


<meta name="google-site-verification" content="E9deYnivN5MuHMuIfiMZZfS0alv-d_0UjcwjBL79lGU" />



<meta name="baidu-site-verification" content="iHYWJxscwD" />










<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />



  <meta name="google-site-verification" content="true" />








  <meta name="baidu-site-verification" content="true" />







  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />







<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.4" rel="stylesheet" type="text/css" />


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=5.1.4">


  <link rel="mask-icon" href="/images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="学习笔记,量化投资,kaggle竞赛,机器学习,模型集成,XGBoost," />










<meta name="description" content="上次尝试了几个机器学习的分类模型，效果都不太好。准确率刚刚超过50%，比瞎猜稍微好一点。提交以后分数最高的还是逻辑回归的2038分。下面实施模型集成。集成把不同模型的预测结果结合起来，生成最终预测，集成的模型越多，效果就越好。另外，由于集成结合了不同的基线预测，它们的性能至少等同于最优的基线模型。集成使得我们几乎免费就获得了性能提升！集成的基本概念：结合多个模型的预测，对特异性误差取平均，从而获得">
<meta property="og:type" content="article">
<meta property="og:title" content="量化投资学习笔记96——kaggle量化投资比赛记录5-模型集成">
<meta property="og:url" content="https://zwdnet.github.io/2021/01/11/%E9%87%8F%E5%8C%96%E6%8A%95%E8%B5%84%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B096%E2%80%94%E2%80%94kaggle%E9%87%8F%E5%8C%96%E6%8A%95%E8%B5%84%E6%AF%94%E8%B5%9B%E8%AE%B0%E5%BD%955-%E6%A8%A1%E5%9E%8B%E9%9B%86%E6%88%90/index.html">
<meta property="og:site_name" content="赵瑜敏的口腔医学专业学习博客">
<meta property="og:description" content="上次尝试了几个机器学习的分类模型，效果都不太好。准确率刚刚超过50%，比瞎猜稍微好一点。提交以后分数最高的还是逻辑回归的2038分。下面实施模型集成。集成把不同模型的预测结果结合起来，生成最终预测，集成的模型越多，效果就越好。另外，由于集成结合了不同的基线预测，它们的性能至少等同于最优的基线模型。集成使得我们几乎免费就获得了性能提升！集成的基本概念：结合多个模型的预测，对特异性误差取平均，从而获得">
<meta property="og:locale">
<meta property="og:image" content="https://zymblog-1258069789.cos.ap-chengdu.myqcloud.com/blog0178-QTLearn/69/01.png">
<meta property="og:image" content="https://zymblog-1258069789.cos.ap-chengdu.myqcloud.com/blog0178-QTLearn/69/02.png">
<meta property="og:image" content="https://zymblog-1258069789.cos.ap-chengdu.myqcloud.com/blog0178-QTLearn/69/03.png">
<meta property="og:image" content="https://zymblog-1258069789.cos.ap-chengdu.myqcloud.com/blog0178-QTLearn/69/04.png">
<meta property="og:image" content="https://zymblog-1258069789.cos.ap-chengdu.myqcloud.com/blog0178-QTLearn/69/05.png">
<meta property="og:image" content="https://zymblog-1258069789.cos.ap-chengdu.myqcloud.com/blog0178-QTLearn/69/06.png">
<meta property="og:image" content="https://zymblog-1258069789.cos.ap-chengdu.myqcloud.com/blog0178-QTLearn/69/07.png">
<meta property="og:image" content="https://zymblog-1258069789.cos.ap-chengdu.myqcloud.com/blog0178-QTLearn/69/08.png">
<meta property="og:image" content="https://zymblog-1258069789.cos.ap-chengdu.myqcloud.com/blog0178-QTLearn/69/09.png">
<meta property="og:image" content="https://zymblog-1258069789.cos.ap-chengdu.myqcloud.com/blog0178-QTLearn/69/10.png">
<meta property="og:image" content="https://zymblog-1258069789.cos.ap-chengdu.myqcloud.com/blog0178-QTLearn/69/11.png">
<meta property="og:image" content="https://zymblog-1258069789.cos.ap-chengdu.myqcloud.com/blog0178-QTLearn/69/12.png">
<meta property="og:image" content="https://zymblog-1258069789.cos.ap-chengdu.myqcloud.com/other/wx.jpg">
<meta property="article:published_time" content="2021-01-11T07:36:06.000Z">
<meta property="article:modified_time" content="2021-01-11T08:01:31.000Z">
<meta property="article:author" content="赵瑜敏">
<meta property="article:tag" content="学习笔记">
<meta property="article:tag" content="量化投资">
<meta property="article:tag" content="kaggle竞赛">
<meta property="article:tag" content="机器学习">
<meta property="article:tag" content="模型集成">
<meta property="article:tag" content="XGBoost">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://zymblog-1258069789.cos.ap-chengdu.myqcloud.com/blog0178-QTLearn/69/01.png">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '',
    scheme: 'Pisces',
    version: '5.1.4',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="https://zwdnet.github.io/2021/01/11/量化投资学习笔记96——kaggle量化投资比赛记录5-模型集成/"/>





  <title>量化投资学习笔记96——kaggle量化投资比赛记录5-模型集成 | 赵瑜敏的口腔医学专业学习博客</title>
  








<meta name="generator" content="Hexo 5.4.0"></head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">赵瑜敏的口腔医学专业学习博客</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle"></p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/%20" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags/%20" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories/%20" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives/%20" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="https://zwdnet.github.io/2021/01/11/%E9%87%8F%E5%8C%96%E6%8A%95%E8%B5%84%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B096%E2%80%94%E2%80%94kaggle%E9%87%8F%E5%8C%96%E6%8A%95%E8%B5%84%E6%AF%94%E8%B5%9B%E8%AE%B0%E5%BD%955-%E6%A8%A1%E5%9E%8B%E9%9B%86%E6%88%90/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="https://zymblog-1258069789.cos.ap-chengdu.myqcloud.com/other/tx.jpg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="赵瑜敏的口腔医学专业学习博客">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">量化投资学习笔记96——kaggle量化投资比赛记录5-模型集成</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2021-01-11T07:36:06+00:00">
                2021-01-11
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E9%87%8F%E5%8C%96%E6%8A%95%E8%B5%84/" itemprop="url" rel="index">
                    <span itemprop="name">量化投资</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          

          

          
            <div class="post-wordcount">
              
                
                  <span class="post-meta-divider">|</span>
                
                <span class="post-meta-item-icon">
                  <i class="fa fa-file-word-o"></i>
                </span>
                
                  <span class="post-meta-item-text">字数统计&#58;</span>
                
                <span title="字数统计">
                  2.3k
                </span>
              

              
                <span class="post-meta-divider">|</span>
              

              
                <span class="post-meta-item-icon">
                  <i class="fa fa-clock-o"></i>
                </span>
                
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                
                <span title="阅读时长">
                  8
                </span>
              
            </div>
          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <p>上次尝试了几个机器学习的分类模型，效果都不太好。准确率刚刚超过50%，比瞎猜稍微好一点。提交以后分数最高的还是逻辑回归的2038分。<br><img src="https://zymblog-1258069789.cos.ap-chengdu.myqcloud.com/blog0178-QTLearn/69/01.png"><br>下面实施模型集成。<br>集成把不同模型的预测结果结合起来，生成最终预测，集成的模型越多，效果就越好。另外，由于集成结合了不同的基线预测，它们的性能至少等同于最优的基线模型。集成使得我们几乎免费就获得了性能提升！<br>集成的基本概念：结合多个模型的预测，对特异性误差取平均，从而获得更好的整体预测结果。<br><img src="https://zymblog-1258069789.cos.ap-chengdu.myqcloud.com/blog0178-QTLearn/69/02.png"><br>stacking：stacking是一种分层模型集成框架。以两层为例，第一层由多个基学习器组成，其输入为原始训练集，第二层的模型则是以第一层基学习器的输出作为特征加入训练集进行再训练，从而得到完整的stacking模型。<br>不同的模型，是在不同的角度观察我们的数据集。<br>基本步骤:<br>①选择基模型。各种基本的机器学习算法。<br>②把训练集分成不交叉的若干份。<br>③将其中一份作为预测集，使用其它份进行建模，预测预测集，保留结果。<br>④把预测结果按照对应的位置填上，得到对整个数据集在第一个基模型上的一个stacking转换。<br>⑤在④的过程中，每个模型分别对测试集进行预测，并保留这五列结果，取平均值，作为该基模型对测试集数据的一个stacking转换。<br>⑥对其它基模型重复②-⑤步。<br>⑦一般使用LR作为第二层的模型进行建模预测。<br><img src="https://zymblog-1258069789.cos.ap-chengdu.myqcloud.com/blog0178-QTLearn/69/03.png"><br>整个过程比较耗时，尽量增加一些不同类型的模型。<br>下面实操<br>用XGBoost。所谓 Boosting ，就是将弱分离器 f_i(x) 组合起来形成强分类器 F(x) 的一种方法。Boost的三个要素:待优化的损失函数，弱的做预测的分类器，附加的模型(将弱的分类器累加起来形成强分类器，进而使目标损失函数达到极小)。<br>先导入库</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">from</span> xgboost <span class="keyword">import</span> XGBClassifier</span><br></pre></td></tr></table></figure>
<p>然后完全用默认参数，用1%的数据在服务器里跑一下看看。</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">model = XGBClassifier()</span><br><span class="line">model.fit(X_train, y_train)</span><br></pre></td></tr></table></figure>
<p><img src="https://zymblog-1258069789.cos.ap-chengdu.myqcloud.com/blog0178-QTLearn/69/04.png"><br><img src="https://zymblog-1258069789.cos.ap-chengdu.myqcloud.com/blog0178-QTLearn/69/05.png"><br>花了2个多小时。<br>在kaggle里提交的时候用了“tree_method=”gpu_hist””参数，使用GPU加速。每周可以使用40小时。真的快了好多。<br><img src="https://zymblog-1258069789.cos.ap-chengdu.myqcloud.com/blog0178-QTLearn/69/06.png"><br>结果还不错。下面试试调参，网上看到一个步骤：<br>①设置一些初始值。<br>②保持learning rate和其他booster相关的参数不变，调节和estimators的参数。<br>③保证estimators和其他的booster参数不变，调节learning rate<br>④保持estimators和learning rate不变，调节booste相关的参数。可以从影响最大的max_depth和min_child_weight开始。逐步调节所有可能影响的booster参数。<br>⑤缩小learning rate,得到最佳的learing rate值。<br>⑥得到一组效果还不错的参数组合。<br>先显示训练时每一步的分数，把训练代码改成</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">model = XGBClassifier()</span><br><span class="line">eval_set = [(X_train, y_train)]</span><br><span class="line">model.fit(X_train, y_train, early_stopping_rounds = <span class="number">10</span>, eval_metric = <span class="string">&quot;logloss&quot;</span>, eval_set = eval_set, verbose = <span class="literal">True</span>)</span><br></pre></td></tr></table></figure>
<p>再输出特征重要性<br><img src="https://zymblog-1258069789.cos.ap-chengdu.myqcloud.com/blog0178-QTLearn/69/07.png"><br>下面来看看XGBoost有哪些参数？分三类：通用参数（General Parameters）、Booster参数、学习目标参数（Task Parameters）。<br>1.通用参数：<br>booster:有gbtree和gblinear两种，前者使用基于树的模型，后者使用线性模型，默认gbtree。<br>silent:运行时是否输出信息，默认为0，不输出。<br>nthread:使用的线程数，默认为可以使用的最大值。<br>num_pbuffer：使用的缓存大小，由xgboost自动设置。<br>num_feature：使用的特征个数，自动设置，不用调。<br>2.tree booster参数<br>eta:更新过程中的收缩步长，即学习率。通过缩减特征的权重使提升计算过程更加保守。缺省为0.3，取值范围[0,1]，通常设置为[0.01,0.2]。<br>gamma:也称min_split_loss，在树的叶节点进行进一步划分时所需的最小损失的减少值，制定了节点分裂所需的最小损失函数下降值。值越大，算法越保守。该值需调节，范围[0,无穷大]，默认为0。<br>max_depth：树的最大深度，缺省为6。取值范围为[1,无穷]，指树的最大深度，树的深度越大，对数据的拟合程度越高（过拟合程度也越高）。控制过拟合。建议通过交叉验证调参，通常3-10。<br>min_child_weight:孩子节点中最小的样本权重和。如果一个叶子节点的样本权重和小于min_child_weight则拆分过程结束。指建立每个模型所需要的最小样本数。控制过拟合。范围[0,无穷大]。默认为1。<br>max_delta_step:在每棵树的权重估计中，允许的最大delta步长。如果为0，意味着没有约束。如果设置为一个正数，有助于在更新步长的时候，使模型更加保守。当类别极度不平衡时，有助于逻辑回归模型的训练。设置为1-10，可能有助于控制更新。取值范围[0,无穷大]。<br>subsample:用于训练模型的子样本占整个样本集合的比例。如果设置为0.5意味着将随机从整个样本集合中抽取出50%的子样本建立树模型，能够防止过拟合。取值范围(0,1]，默认1。<br>colsample_bytree:在建立树时对特征随机采样的比例。缺省值为1，取值范围(0,1]。<br>colsample_bylevel:决定每次节点划分时子样例的比例。通常不使用。<br>scale_pos_weight:大于0的取值可以处理类别不平衡的情况，帮助模型更快收敛。<br>3.Linear Booster参数<br>lambda:L2正则的惩罚系数，用于处理正则化部分，通常不使用，但可以用来降低过拟合。<br>alpha:L1正则的惩罚系数，当数据维度极高时可以使用，使得算法运行更快。<br>lambda_bias:在偏置上的L2正则，缺省为0.<br>4.学习目标参数<br>objective:定义学习任务及相应的学习目标。<br>“reg:linear”线性回归<br>“reg:logistic”逻辑回归<br>“binary:logistic”二分类的逻辑回归问题，输出为概率。<br>“binary:logitraw”二分类的逻辑回归问题，输出结果为wTx。<br>“count:poisson”计数问题的poisson回归，输出结果为poisson分布。<br>“multi:softmax”让XGBoost采用softmax目标函数处理多分类问题，同时需要设置参数num_class(类别个数）<br>“multi:softprob”同上，但输出是ndata×nclass的向量，可以将该向量reshape成ndata行nclass列的矩阵。每行数据表示样本所属于每个类别的概率。<br>“rank:pairwise”采用评分机制进行训练。<br>默认为”reg:linear”<br>base_score:所有实例的初始化预测分数，全局偏置。为了足够的迭代次数，改变这个值将不会有太大的影响。<br>eval_metric:校验数据所需要的评价指标，不同目标函数将会有缺省的评价指标。用户可以添加，用list传递参数给程序，而不是map参数。可选的有”rmse”,”logloss”,”error”,”merror”,”mlogloss”,”auc”,”ndcg”,”map”……<br>seed：随机数种子，缺省为0。<br>采用字典方式提供parms参数，即为上述参数的”名称”:值的形式。<br>先按网站1的方法调参。<br>先调learning_rate, tree_depth, subsample三个参数。<br>学习率</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">tc</span>(<span class="params">X, Y</span>):</span></span><br><span class="line">    model = XGBClassifier(use_label_encoder=<span class="literal">False</span>, eval_metric = <span class="string">&quot;logloss&quot;</span>)</span><br><span class="line">    learning_rate = [<span class="number">0.0001</span>, <span class="number">0.001</span>, <span class="number">0.01</span>, <span class="number">0.1</span>, <span class="number">0.2</span>, <span class="number">0.3</span>]</span><br><span class="line">    param_grid = <span class="built_in">dict</span>(learning_rate=learning_rate)</span><br><span class="line">    kfold = StratifiedKFold(n_splits=<span class="number">10</span>, shuffle=<span class="literal">True</span>, random_state=<span class="number">7</span>)</span><br><span class="line">    grid_search = GridSearchCV(model, param_grid, scoring=<span class="string">&quot;neg_log_loss&quot;</span>, n_jobs=-<span class="number">1</span>, cv=kfold)</span><br><span class="line">    grid_result = grid_search.fit(X, Y)</span><br><span class="line">    print(<span class="string">&quot;Best: %f using %s&quot;</span> % (grid_result.best_score_, grid_result.best_params_))</span><br><span class="line">    <span class="comment"># 输出每个学习率对应分数</span></span><br><span class="line">    means = grid_result.cv_results_[<span class="string">&#x27;mean_test_score&#x27;</span>]</span><br><span class="line">    stds = grid_result.cv_results_[<span class="string">&#x27;std_test_score&#x27;</span>]</span><br><span class="line">    params = grid_result.cv_results_[<span class="string">&#x27;params&#x27;</span>]</span><br><span class="line">    y = []</span><br><span class="line">    <span class="keyword">for</span> mean, stdev, param <span class="keyword">in</span> <span class="built_in">zip</span>(means, stds, params):</span><br><span class="line">        print(<span class="string">&quot;%f (%f) with: %r&quot;</span> % (mean, stdev, param))</span><br><span class="line">        y.append(mean)</span><br><span class="line">    plt.plot(learning_rate, y)</span><br><span class="line">    plt.savefig(<span class="string">&quot;./output/learning_rate.png&quot;</span>)</span><br></pre></td></tr></table></figure>
<p>0.1最佳。<br><img src="https://zymblog-1258069789.cos.ap-chengdu.myqcloud.com/blog0178-QTLearn/69/08.png"><br>提交看看<br><img src="https://zymblog-1258069789.cos.ap-chengdu.myqcloud.com/blog0178-QTLearn/69/09.png"><br>不错，提高了800多分。<br>再试试max_depth参数。<br><img src="https://zymblog-1258069789.cos.ap-chengdu.myqcloud.com/blog0178-QTLearn/69/10.png"><br>最好的是3，但345差不多。<br><img src="https://zymblog-1258069789.cos.ap-chengdu.myqcloud.com/blog0178-QTLearn/69/11.png"><br>用3，提交一次看看。<br><img src="https://zymblog-1258069789.cos.ap-chengdu.myqcloud.com/blog0178-QTLearn/69/12.png"><br>看来是欠拟合了。还可以进行其它参数的调整测试，先掌握方法，到这里吧。跑一次提交太慢了，要几个小时才看得到结果。目前为止我自己折腾的最高分是3903分，下次该考虑用深度学习试试了。<br>本文代码： <a target="_blank" rel="noopener" href="https://github.com/zwdnet/JSMPwork/blob/main/myxgboost.py">https://github.com/zwdnet/JSMPwork/blob/main/myxgboost.py</a></p>
<p>参考资料：<br>[1]<a target="_blank" rel="noopener" href="https://www.jianshu.com/p/7e0e2d66b3d4">https://www.jianshu.com/p/7e0e2d66b3d4</a><br>[2]<a target="_blank" rel="noopener" href="https://xgboost.readthedocs.io/en/latest/">https://xgboost.readthedocs.io/en/latest/</a><br>[3]<a target="_blank" rel="noopener" href="https://cloud.tencent.com/developer/article/1387686">https://cloud.tencent.com/developer/article/1387686</a><br>[4]<a target="_blank" rel="noopener" href="https://zhuanlan.zhihu.com/p/28672955">https://zhuanlan.zhihu.com/p/28672955</a><br>[5]<a target="_blank" rel="noopener" href="https://blog.csdn.net/qq_30868737/article/details/108010935">https://blog.csdn.net/qq_30868737/article/details/108010935</a><br>[6]<a target="_blank" rel="noopener" href="https://blog.csdn.net/weixin_41580067/article/details/86514402">https://blog.csdn.net/weixin_41580067/article/details/86514402</a><br>[7]<a target="_blank" rel="noopener" href="https://blog.csdn.net/qq_30868737/article/details/108385115">https://blog.csdn.net/qq_30868737/article/details/108385115</a></p>
<p>我发文章的三个地方，欢迎大家在朋友圈等地方分享，欢迎点“在看”。<br>我的个人博客地址：<a href="https://zwdnet.github.io/">https://zwdnet.github.io</a><br>我的知乎文章地址： <a target="_blank" rel="noopener" href="https://www.zhihu.com/people/zhao-you-min/posts">https://www.zhihu.com/people/zhao-you-min/posts</a><br>我的微信个人订阅号：赵瑜敏的口腔医学学习园地</p>
<p><img src="https://zymblog-1258069789.cos.ap-chengdu.myqcloud.com/other/wx.jpg"></p>

      
    </div>
    
    
    

    

    
      <div>
        <div style="padding: 10px 0; margin: 20px auto; width: 90%; text-align: center;">
  <div>欢迎打赏！感谢支持！</div>
  <button id="rewardButton" disable="enable" onclick="var qr = document.getElementById('QR'); if (qr.style.display === 'none') {qr.style.display='block';} else {qr.style.display='none'}">
    <span>打赏</span>
  </button>
  <div id="QR" style="display: none;">

    
      <div id="wechat" style="display: inline-block">
        <img id="wechat_qr" src="https://zymblog-1258069789.cos.ap-chengdu.myqcloud.com/other/mm_facetoface_collect_qrcode_1542944836634.png" alt=" 微信支付"/>
        <p>微信支付</p>
      </div>
    

    
      <div id="alipay" style="display: inline-block">
        <img id="alipay_qr" src="https://zymblog-1258069789.cos.ap-chengdu.myqcloud.com/other/1542944857770.jpg" alt=" 支付宝"/>
        <p>支付宝</p>
      </div>
    

    

  </div>
</div>

      </div>
    

    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/" rel="tag"># 学习笔记</a>
          
            <a href="/tags/%E9%87%8F%E5%8C%96%E6%8A%95%E8%B5%84/" rel="tag"># 量化投资</a>
          
            <a href="/tags/kaggle%E7%AB%9E%E8%B5%9B/" rel="tag"># kaggle竞赛</a>
          
            <a href="/tags/%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0/" rel="tag"># 机器学习</a>
          
            <a href="/tags/%E6%A8%A1%E5%9E%8B%E9%9B%86%E6%88%90/" rel="tag"># 模型集成</a>
          
            <a href="/tags/XGBoost/" rel="tag"># XGBoost</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2021/01/10/%E5%B0%9D%E8%AF%95%E5%8D%B0%E7%AB%A0%E6%B3%95%E6%A0%91%E8%84%82%E5%85%85%E5%A1%AB%E4%B8%80%E4%BE%8B/" rel="next" title="尝试印章法树脂充填一例">
                <i class="fa fa-chevron-left"></i> 尝试印章法树脂充填一例
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2021/01/16/%E9%87%8F%E5%8C%96%E6%8A%95%E8%B5%84%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B097%E2%80%94%E2%80%94kaggle%E9%87%8F%E5%8C%96%E6%8A%95%E8%B5%84%E6%AF%94%E8%B5%9B%E8%AE%B0%E5%BD%956-%E6%B7%B1%E5%BA%A6%E5%AD%A6%E4%B9%A0%E6%A8%A1%E5%9E%8B/" rel="prev" title="量化投资学习笔记97——kaggle量化投资比赛记录6-深度学习模型">
                量化投资学习笔记97——kaggle量化投资比赛记录6-深度学习模型 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          

  
    <div class="comments" id="comments">
      <div id="lv-container" data-id="city" data-uid="MTAyMC80MTA2Mi8xNzU4Nw=="></div>
    </div>

  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      

      <section class="site-overview-wrap sidebar-panel sidebar-panel-active">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <img class="site-author-image" itemprop="image"
                src="https://zymblog-1258069789.cos.ap-chengdu.myqcloud.com/other/tx.jpg"
                alt="" />
            
              <p class="site-author-name" itemprop="name"></p>
              <p class="site-description motion-element" itemprop="description"></p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/archives/%20%7C%7C%20archive">
              
                  <span class="site-state-item-count">452</span>
                  <span class="site-state-item-name">日志</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-categories">
                <a href="/categories/index.html">
                  <span class="site-state-item-count">29</span>
                  <span class="site-state-item-name">分类</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-tags">
                <a href="/tags/index.html">
                  <span class="site-state-item-count">544</span>
                  <span class="site-state-item-name">标签</span>
                </a>
              </div>
            

          </nav>

          

          

          
          

          
          

          

        </div>
      </section>

      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2021</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">本站版权归赵瑜敏所有，如欲转载请与本人联系。</span>

  
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-area-chart"></i>
    </span>
    
      <span class="post-meta-item-text">Site words total count&#58;</span>
    
    <span title="Site words total count">1225.8k</span>
  
</div>









<div>
  <script type="text/javascript">var cnzz_protocol = (("https:" == document.location.protocol) ? " https://" : " http://");document.write(unescape("%3Cspan id='cnzz_stat_icon_1275447216'%3E%3C/span%3E%3Cscript src='" + cnzz_protocol + "s11.cnzz.com/z_stat.php%3Fid%3D1275447216%26online%3D1%26show%3Dline' type='text/javascript'%3E%3C/script%3E"));</script>
</div>

        







  <div style="display: none;">
    <script src="//s95.cnzz.com/z_stat.php?id=1275447216&web_id=1275447216" language="JavaScript"></script>
  </div>



        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  
    <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.4"></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v=5.1.4"></script>



  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.4"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.4"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  
    <script type="text/javascript">
      (function(d, s) {
        var j, e = d.getElementsByTagName(s)[0];
        if (typeof LivereTower === 'function') { return; }
        j = d.createElement(s);
        j.src = 'https://cdn-city.livere.com/js/embed.dist.js';
        j.async = true;
        e.parentNode.insertBefore(j, e);
      })(document, 'script');
    </script>
  












  





  

  

  

  
  

  

  

  

  
</body>
</html>
